package edu.cque.sp03.controller;

import edu.cque.sp01.entity.User;
import edu.cque.sp01.service.UserService;
import edu.cque.sp01.web.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Hua
 * @create 2022-08-17 17:38
 */
@RestController
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping("/{userId}")
    public JsonResult getUser(@PathVariable Integer userId) {
        User u = userService.getUser(userId);
        return JsonResult.ok().data(u);
    }

    @GetMapping("/{userId}/score")
    public JsonResult<?> addScore(@PathVariable Integer userId, Integer score) {
        userService.addScore(userId, score);
        return JsonResult.ok().msg("增加积分成功");
    }
    @GetMapping("/favicon.ico")
    public void ico(){
        System.out.println("user: 浏览器访问的时候,会默认发送这个接口的请求,用来辨别网站返回的图标");
    }

}
//class b<E> {
//
//   <T> List<T> build(E e){
//        return null;
//    }
//
//    public void main(String[] args) {
//       E d = null;
//        new b().build(d);
//    }
//}
